package com.adgox.tiantianbiting.mine.TingCoinWithdraw;

import com.adgox.tiantianbiting.bean.BaseResponseBean;
import com.adgox.tiantianbiting.mine.tingCoinRecord.TingCoinRecordContract;
import com.adgox.tiantianbiting.net.callback.JsonCallback;
import com.adgox.tiantianbiting.utils.ApiConstant;
import com.adgox.tiantianbiting.utils.DialogUtils;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Response;

/**
 * Created by tang on 2019/3/25.
 */

public class TingCoinWithdrawPresenterImpl implements TingCoinWithdrawContract.Presenter {
    TingCoinWithdrawContract.View mView;

    @Override
    public void start() {

    }

    public TingCoinWithdrawPresenterImpl(TingCoinWithdrawContract.View mView) {
        this.mView = mView;
        mView.setPresenter(this);
    }

    //发送验证码
    @Override
    public void sendVert(String mobile,int userId) {
        OkGo.<BaseResponseBean<String>>post(ApiConstant.BASE_URL+ApiConstant.GET_VERTIFY_CODE+mobile+"/"+userId)
                .execute(new JsonCallback<BaseResponseBean<String>>() {
                    @Override
                    public void onSuccess(Response<BaseResponseBean<String>> response) {
                        DialogUtils.dismiss();
                        if ("0".equals(response.body().getCode())) {
                            mView.onGetVertSuccess();
                        } else {
                            mView.onGetVertFailed(response.body().getMessage());
                        }
                    }
                });
    }

    @Override
    public void checkVert(String s) {
        OkGo.<BaseResponseBean<String>>post(ApiConstant.BASE_URL+ApiConstant.CHECK_VERTIFY_CODE)
                .upJson(s)
                .execute(new JsonCallback<BaseResponseBean<String>>() {
                    @Override
                    public void onSuccess(Response<BaseResponseBean<String>> response) {
                        DialogUtils.dismiss();
                        if ("0".equals(response.body().getCode())){
                            mView.onCheckVertSuccess();
                        } else {
                            mView.onGetVertFailed(response.body().getMessage());
                        }
                    }
                });
    }
}
